import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

import { getDictOptions } from '#/utils/dict';
import { renderDict } from '#/utils/render';

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'RadioGroup',
    componentProps: {
      buttonStyle: 'solid',
      optionType: 'button',
    },
    fieldName: 'status',
    label: '状态',
  },
  {
    component: 'Input',
    fieldName: 'interactionName',
    label: '互动名称',
  },
  {
    component: 'Input',
    fieldName: 'employeeId',
    label: '数字员工ID',
  },
  {
    component: 'Select',
    componentProps: {
      // 可选从DictEnum中获取 DictEnum.SYS_NOTICE_TYPE 便于维护
      options: getDictOptions('sys_notice_type'),
    },
    fieldName: 'interactionInfo',
    label: '互动内容',
  },
  {
    component: 'Input',
    fieldName: 'flowableId',
    label: '工作流',
  },
  {
    component: 'Input',
    fieldName: 'isDel',
    label: '软删除',
  },
  {
    component: 'Input',
    fieldName: 'keyword',
    label: '关键词',
  },
  {
    component: 'Input',
    fieldName: 'auditorId',
    label: '鉴定师',
  },
  {
    component: 'Input',
    fieldName: 'maxDays',
    label: '笔记回复的发布时间的最近天数',
  },
  {
    component: 'Input',
    fieldName: 'locationFilter',
    label: '区域限制',
  },
];

// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// export const columns: () => VxeGridProps['columns'] = () => [
export const columns: VxeGridProps['columns'] = [
  { type: 'checkbox', width: 60 },
  {
    title: '主键',
    field: 'id',
  },
  {
    title: '状态',
    field: 'status',
  },
  {
    title: '互动名称',
    field: 'interactionName',
  },
  {
    title: '数字员工ID',
    field: 'employeeId',
  },
  {
    title: '互动内容',
    field: 'interactionInfo',
    slots: {
      default: ({ row }) => {
        // 可选从DictEnum中获取 DictEnum.SYS_NOTICE_TYPE 便于维护
        return renderDict(row.interactionInfo, 'sys_notice_type');
      },
    },
  },
  {
    title: '工作流',
    field: 'flowableId',
  },
  {
    title: '软删除',
    field: 'isDel',
  },
  {
    title: '关键词',
    field: 'keyword',
  },
  {
    title: '鉴定师',
    field: 'auditorId',
  },
  {
    title: '笔记回复的发布时间的最近天数',
    field: 'maxDays',
  },
  {
    title: '区域限制',
    field: 'locationFilter',
  },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    width: 180,
  },
];

export const modalSchema: FormSchemaGetter = () => [
  {
    label: '主键',
    fieldName: 'id',
    component: 'Input',
    dependencies: {
      show: () => false,
      triggerFields: [''],
    },
  },
  {
    label: '状态',
    fieldName: 'status',
    component: 'RadioGroup',
    componentProps: {
      buttonStyle: 'solid',
      optionType: 'button',
    },
    rules: 'selectRequired',
  },
  {
    label: '互动名称',
    fieldName: 'interactionName',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '数字员工ID',
    fieldName: 'employeeId',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '互动内容',
    fieldName: 'interactionInfo',
    component: 'Select',
    componentProps: {
      // 可选从DictEnum中获取 DictEnum.SYS_NOTICE_TYPE 便于维护
      options: getDictOptions('sys_notice_type'),
    },
    rules: 'selectRequired',
  },
  {
    label: '工作流',
    fieldName: 'flowableId',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '软删除',
    fieldName: 'isDel',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '关键词',
    fieldName: 'keyword',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '鉴定师',
    fieldName: 'auditorId',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '笔记回复的发布时间的最近天数',
    fieldName: 'maxDays',
    component: 'Input',
    rules: 'required',
  },
  {
    label: '区域限制',
    fieldName: 'locationFilter',
    component: 'Input',
    rules: 'required',
  },
];
